package com.wc.alorithm_luogu.P1157;

import java.util.Scanner;

/**
 * @Author congege
 *
 * @Description 组合的输出
 * https://www.luogu.com.cn/problem/P1157
 * @Date Created in 2023/9/17-14:55
 */
public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int r = scan.nextInt();
        Main main = new Main();
        int[] array = new int[n];
        for (int i = 1; i <=n ; i++) {
            array[i - 1] = i ;
        }
        main.printCombination(array,0,0,new int[r]);
    }

    public void printCombination(int[] array, int index, int floor, int[] printArray) {
        if (floor == printArray.length) {
            for (int number : printArray) {
                System.out.printf("%3d", number);
            }
            System.out.println();
            return;
        }
        int len = array.length;
        for (int i = index; i < len; i++) {
            printArray[floor] = array[i];
            printCombination(array, i + 1, floor + 1, printArray);
        }
    }
}
